"use strict";
advertiserApp.controller("advertiserCtrl",function($scope,$http){
     $scope.msgId = getQueryString("msgId");       
	 //获取信件内容;
	 $.ajax({
	     type:"post",
		 dataType:"json",
		 url:"/web-adv/readMsgInbox",
		 data:{msgId:$scope.msgId},
		 success:function(data){
		     console.log(data);			 
			 if(data){
			     $scope.arr = data;
			     $("#sender_name").val(data.sender_name);
		         $("#msgTitle").val(data.mail_title);
				 var replyHtml = "<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>"+
	                 "<p style='font-weight:700;font-size:20px;'>---------***原始邮件***---------</p>"+
	                 "<div style='font-size:14px;line-height:30px;'><span>发件人：</span><span>"+data.sender_name+"</span></div>"+
	                 "<div style='font-size:14px;line-height:30px;'><span>时间：</span><span>"+data.create_time+"</span></div>"+
	                 "<div style='font-size:14px;line-height:30px;'><span>收件人：</span><span>"+data.addressee_name+"</span></div>"+
	                 "<div style='font-size:14px;line-height:30px;'><span>主题：</span><span>"+data.mail_title+"</span></div>"+
	                 "<div><br/><br/>"+data.mail_content+"</div>";
                 $("#editBox").val(replyHtml);					 
			 }
		 }
	 });		 
	 //发送信件;
	 $scope.replyMsg = function(){
	     //console.log(editor.getSource());
	     $http.post("/web-adv/replyMsg","json",{sender_id:$scope.arr.addressee_id,addressee_id:$scope.arr.sender_id,mail_title:$scope.msgTitle,mail_content:editor.getSource()}).success(function(data){
		     console.log(data);
			 
		 }); 
		 //window.location.href="/web-adv/advWeb/views/message/sendSuccess.html?selectedNav=6&navPos=0"
	 };
	 //追加回复邮件内容
	 /* $scope.replyHtml = "<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>"+
	 "<p style='font-weight:700;font-size:20px;'>---------***原始邮件***---------</p>"+
	 "<div style='font-size:14px;line-height:30px;'><span>发件人：</span><span>"+data.sender_name+"</span></div>"+
	 "<div style='font-size:14px;line-height:30px;'><span>时间：</span><span>"+data.creat_time+"</span></div>"+
	 "<div style='font-size:14px;line-height:30px;'><span>收件人：</span><span>"+data.addressee_name+"</span></div>"+
	 "<div style='font-size:14px;line-height:30px;'><span>主题：</span><span>"+data.mail_title+"</span></div>"+
	 "<div><br/><br/>"+"data.msg_content"+"</div>"; */
	 
});
/* var data ={
     id:"10001",
	 sender_id:"admin001",
	 sender_name:"管理员tester1",
	 sender_type:"管理员",
	 addressee_id:"ad0001",
	 addressee_name:"广告主tester1",
	 addressee_type:"广告主",
	 mail_prefix:"站内信标题前缀",
	 mail_title:"站内信标题",
	 creat_time:"2014-10-23",
	 msg_content:"信件内容信件内容信件内容信件内容信件内容信件内容信件内容信件内容信件内容信件内容"
} */